package com.j1ay.forum.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.j1ay.forum.model.pojo.po.Permission;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author J1ay
 * @Date 2021/12/18 20:46
 * @Description
 */


public interface PermissionMapper extends BaseMapper<Permission> {

    @Select("SELECT * FROM tb_permission WHERE tb_permission.id IN " +
            "(SELECT permissionId FROM tb_role_permission WHERE tb_role_permission.roleId = " +
            "(SELECT tb_role.id FROM tb_role WHERE tb_role.id = #{id}))")
    List<Permission> findPermissionsByRoleId(Long roleId);
}
